#ifndef __uentry_h__
#define __uentry_h__ 1
#include "sys.h"
#include "log.h"
#include "net.h"
typedef struct{
    int fd;
    uint16_t port;
    struct sockaddr_in peer_addr, local_addr;
    socklen_t peer_addr_len;
}uentry_t;

typedef struct{
    uint64_t bytes;
    uint64_t packets;
    int duration;//ms
}uentry_trans_info_t;

uentry_t *uentry_new();
int uentry_bind(uentry_t* ue);
void uentry_free(uentry_t *ue);
void* uentry_run(void* arg);
int ratelimit(uint64_t start_us, uint64_t cur_bytes, uint64_t limit_rate);
#endif